import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_style.dart';
import 'package:love_newf/app/page/live/live_logic.dart';
import 'package:love_newf/value/app_const.dart';

class LiveChatEditView extends StatefulWidget {
  const LiveChatEditView({super.key});

  @override
  State<LiveChatEditView> createState() => _LiveChatEditViewState();
}

class _LiveChatEditViewState extends State<LiveChatEditView> {
  LiveLogic logic = Get.find<LiveLogic>();
  String msg = "";

  @override
  Widget build(BuildContext context) {
    return LStack([
      Align(
          alignment: Alignment.bottomLeft,
          child: LRow.eazy([inputBox, 10.lsw, sendBtn])
              .paddingAll(10.w)
              .bgColor(Colors.blueGrey)
              .size(375.w, null))
    ]).onTapL(() {
      logic.showChatEdit = false;
      logic.chatEditFocusNode.unfocus();
      logic.update();
    }).size(double.infinity, double.infinity);
  }

  get sendBtn => LText.easy('发送', 18.sp, fw7, Colors.white)
      .gradient(const [Color(0xFFFE3EC9), Color(0xFFFB1D76), Color(0xFFFFA253)],
          Alignment.centerRight)
      .radius(15.w)
      .center()
      .size(63.w, 50.w)
      .onTapL(() {
        logic.sendTextMessage(msg);
      });

  get inputBox => LInput(
        focusNode: logic.chatEditFocusNode,
        msg,
        lStyle: LStyle(
            hintText: "",
            flex: 1,
            backgroundColor: Colors.white,
            radius: 12.w,
            padding: EdgeInsets.only(left: 10.w, top: 10.w, bottom: 10.w)),
      ).onChange((text) => msg = text);
}
